import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


// 不要忘记注解路径
@WebServlet("/method")
public class MethodServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        System.out.println("doGet");
        // utf8 或者 utf-8 都可以的
        resp.setContentType("text/html;charset=utf-8");

        resp.getWriter().write("执行了doGet这个方法");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("doPost");

        resp.getWriter().write("doPost");

    }

    @Override
    public void destroy() {
        System.out.println("destroy");

    }

    @Override
    protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("delete");
        //写到浏览器中
        resp.getWriter().write("delete");
    }
}
